<?php
	/**
	 * @package AmpleHarvest
	 */
	/**
	 * @brief This class controls the whole Classification Object
	 *
	 * - Revision History
	 *  - 0.1
	 * 	 - <b>Date</b>: 20 MAY 2011
	 * 	 - <b>Author</b>: Randy Blancett
	 * 	  - Initial Version
	 *
	 * @author Randy Blancett
	 * @version 0.1
	 * @ingroup code classes
	 */
	class cClassification
	{
		const C_INT_CLASS_UNCLASSIFIED = 0;

		const C_INT_DISTRO_NONE = 0;
		const C_INT_DISTRO_FOUO = 1;

		const C_INT_ARRAY_CLASS_TITLE = 0;
		const C_INT_ARRAY_CLASS_PORTION = 1;

		protected $m_arr_Class = null;
		protected $m_arr_SCI = null;
		protected $m_arr_Distro = null;
		protected $m_int_Class = -1;

		protected $m_int_CurClassSCI = null;
		protected $m_int_CurClassDistro = null;

		public function getClassArray()
		{
			if (isset($this->m_arr_Class))
			{
				return $this->m_arr_Class;
			}
			return $this->buildClassArray();
		}

		public function getSCIArray()
		{
			if ($this->m_int_Class < 0)
			{
				return array();
			}

			if (isset($this->m_arr_SCI) && ($this->m_int_Class == $this->m_int_CurClassSCI))
			{
				return $this->m_arr_SCI;
			}
			return $this->buildSCIArray();
		}

		public function getDistroArray()
		{
			if ($this->m_int_Class < 0)
			{
				return array();
			}

			if (isset($this->m_arr_Distro) && ($this->m_int_Class == $this->m_int_CurClassDistro))
			{
				return $this->m_arr_Distro;
			}
			return $this->buildDistroArray();
		}

		protected function buildClassArray()
		{
			$this->m_arr_Class = array();

			$this->m_arr_Class[self::C_INT_CLASS_UNCLASSIFIED] = array();
			$this->m_arr_Class[self::C_INT_CLASS_UNCLASSIFIED][self::C_INT_ARRAY_CLASS_TITLE] = "UNCLASSIFIED";
			$this->m_arr_Class[self::C_INT_CLASS_UNCLASSIFIED][self::C_INT_ARRAY_CLASS_PORTION] = "U";

			return $this->m_arr_Class;
		}

		protected function buildSCIArray()
		{
			$this->m_arr_SCI = array();
			$this->m_int_CurClassSCI = $this->m_int_Class;

			switch ($this->m_int_Class)
			{
				case self::C_INT_CLASS_UNCLASSIFIED:
					return $this->m_arr_SCI;
					break;
				default:
					return $this->m_arr_SCI;
					break;
			}

		}

		protected function buildDistroArray()
		{
			$this->m_arr_Distro = array();

			$this->m_int_CurClassDistro = $this->m_int_Class;

			switch ($this->m_int_Class)
			{
				case self::C_INT_CLASS_UNCLASSIFIED:
					$this->m_arr_Distro[self::C_INT_DISTRO_NONE] = array();
					$this->m_arr_Distro[self::C_INT_DISTRO_NONE][self::C_INT_ARRAY_CLASS_TITLE] = "";
					$this->m_arr_Distro[self::C_INT_DISTRO_NONE][self::C_INT_ARRAY_CLASS_PORTION] = "";

					$this->m_arr_Distro[self::C_INT_DISTRO_FOUO] = array();
					$this->m_arr_Distro[self::C_INT_DISTRO_FOUO][self::C_INT_ARRAY_CLASS_TITLE] = "FOR OFFICIAL USE ONLY";
					$this->m_arr_Distro[self::C_INT_DISTRO_FOUO][self::C_INT_ARRAY_CLASS_PORTION] = "FOUO";
					return $this->m_arr_Distro;
					break;
				default:
					return $this->m_arr_Distro;
					break;
			}

		}

		public function setClass($int_Class)
		{
			$this->m_int_Class = $int_Class;
		}

		public function setClassFromTitle($str_Title)
		{
			foreach ($this->getClassArray() as $int_Key => $arr_Class)
			{
				if ($arr_Class[self::C_INT_ARRAY_CLASS_TITLE] == $str_Title)
				{
					$this->setClass($int_Key);
					return true;
				}
			}

			$this->setClass(-1);
			return false;
		}
	}
